//
//  DSZDingDanViewController.m
//  7.13苏宁框架
//
//  Created by app05 on 15/7/24.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZDingDanViewController.h"
#import "DSZMainHeaderView.h"
#import "DSZMoreView.h"
#import "MBProgressHUD.h"
#import "DSZLoginViewController.h"
#import "DSZMainViewController.h"
#import "HomeViewController.h"
#import "DSZShopViewController.h"
@interface DSZDingDanViewController ()<tableViewIndexPathRowDelegate>
- (IBAction)back;
- (IBAction)btn0:(id)sender;
- (IBAction)more;
- (IBAction)segemented:(UISegmentedControl *)sender;

- (IBAction)btn1:(id)sender;
- (IBAction)btn2:(id)sender;
- (IBAction)btn3:(id)sender;

@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (weak, nonatomic) IBOutlet UILabel *inforLabel;
@property (strong, nonatomic) IBOutlet UIView *indexView;
@property (weak, nonatomic) IBOutlet UIView *otherList;

@property(nonatomic,weak)UIView *moreView;
@property(nonatomic,assign)BOOL flag;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation DSZDingDanViewController

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.alpha=0;
    //[self.otherList setTranslatesAutoresizingMaskIntoConstraints:YES];
   

}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //self.view.alpha=0;
    

    //[self performSelectorInBackground:@selector(num) withObject:nil];
    
    
    
}
//-(void)num
//{
//    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//    NSString *str= [defaults objectForKey:@"zh2"];
//    if (![str isEqualToString:@"disizu"]) {
//        DSZLoginViewController *vc=[[DSZLoginViewController alloc]init];
//        
//        [self.navigationController pushViewController:vc animated:YES];
//    }
//    else
//    {
//        
//    }
//    self.view.alpha=1;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)back {
    //DSZMainHeaderView *main=[[DSZMainHeaderView alloc]init];
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (IBAction)btn0:(id)sender {
    [self thransformIndexView:0 ];
}

- (IBAction)more {
    if (!self.flag) {
        DSZMoreView *more=[DSZMoreView moreView];
        more.delegate=self;
        more.frame=CGRectMake(185, 65, 146, 186);
        self.moreView=more;
        [self.view addSubview:self.moreView];
        self.flag=YES;
    }
    else
    {
        [self.moreView removeFromSuperview];
        self.moreView=nil;
        self.flag=NO;
    }

}

- (IBAction)segemented:(UISegmentedControl *)sender {
    
    if (sender.selectedSegmentIndex==0) {
        self.otherList.hidden=YES;
    }else
        self.otherList.hidden=NO;
}

-(void)dszMoreViewWithIndexRow:(NSInteger)indexPathRow
{
    if (indexPathRow==0) {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DSZMainViewController *main=[story instantiateViewControllerWithIdentifier:@"main"];
        //DSZMainViewController *main=[[DSZMainViewController alloc]init];
        [self presentViewController: main animated:NO completion:nil];
    }else if (indexPathRow==1)
    {}
    else if (indexPathRow==2)
    {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        
        DSZShopViewController *shop=[story instantiateViewControllerWithIdentifier:@"shop"];
        [self.navigationController pushViewController:shop animated:NO];
        self.flag=YES;
        [self more];
        self.navigationController.navigationBar.alpha=1;
        DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
        [main hiddenMainTabbar:YES];
    }else if (indexPathRow==3)
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
    
}

- (IBAction)btn1:(id)sender {
    [self thransformIndexView:1];
}

- (IBAction)btn2:(id)sender {
    [self thransformIndexView:2];
}

- (IBAction)btn3:(id)sender {
    [self thransformIndexView:3 ];
}
-(void)thransformIndexView:(NSInteger )tag
{
    //MBProgressHUD
    //self .scrollView.contentOffset=CGPointMake(320*tag, 0);
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.2];
    
    self.indexView.frame=CGRectMake(80*tag, 35, 80, 2);
    self .scrollView.contentOffset=CGPointMake(320*tag, 0);
    [UIView commitAnimations];
}
@end
